classdef Tamagawa_Get_Last10_Position_and_Angle < matlab.System ...
        & coder.ExternalDependency ...
        & matlab.system.mixin.Propagates ...
        & matlab.system.mixin.CustomIcon
    %
    % Get single turn position packet from the Tamagawa Encoder.
    % (Encoder Data ID = 0)
    %
    
    % Copyright 2016 The MathWorks, Inc.
    %#codegen
    %#ok<*EMCA>
    
    properties
        % Public, tunable properties.
    end
    
    properties (Nontunable)
        % Public, non-tunable properties.
    end
    
    properties (Access = private)
        % Pre-computed constants.
    end
    
    methods
        % Constructor
        function obj = Tamagawa_Get_Last10_Position_and_Angle(varargin)
            % Support name-value pair arguments when constructing the object.
            setProperties(obj,nargin,varargin{:});
        end
    end
    
    
    methods (Access=protected)
        function setupImpl(obj) %#ok<MANU>
            if isempty(coder.target)
                % Place simulation setup code here
            else
                % Call C-function implementing device initialization
            end
        end
        
        function [current_position, ElecAngle, last10_position] = stepImpl(obj,new_position,status)
            current_position = int32(new_position);
            last10_position = int32(0);
            ElecAngle = double(0);
            if isempty(coder.target)
                % Place simulation output code here
            else
                % Call C-function implementing device output
                last10_position = coder.ceval('Tamagawa_Get_Last10_Position_and_Angle', coder.wref(current_position), coder.wref(ElecAngle), status);
            end
        end
        
        function releaseImpl(obj) %#ok<MANU>
            if isempty(coder.target)
                % Place simulation termination code here
            else
                % Call C-function implementing device termination
                %coder.ceval('source_terminate');
            end
        end
    end
    
    methods (Access=protected)
        %% Define output properties
        function num = getNumInputsImpl(~)
            num = 2;
        end
        
        function num = getNumOutputsImpl(~)
            num = 3;
        end
        
        function flag = isOutputSizeLockedImpl(~,~)
            flag = true;
        end
        
        function [out1,out2,varargout] = isOutputFixedSizeImpl(~,~)
            out1 = true;
            out2 = true;
            varargout{1} = true;
            
        end
        
        function flag = isOutputComplexityLockedImpl(~,~)
            flag = true;
        end
        
        function [out1,out2,varargout] = isOutputComplexImpl(~)
            out1 = false;
            out2 = false;
            varargout{1} = false;
        end
        
        function [out1,out2,varargout] = getOutputSizeImpl(~)
            out1 = [1,1];
            out2 = [1,1];
            varargout{1} = [1,1];
        end
        
        function [out1,out2,varargout] = getOutputDataTypeImpl(~)
            out1 = 'int32';
            out2 = 'double';
            varargout{1} = 'int32';
        end
        
        function icon = getIconImpl(~)
            % Define a string as the icon for the System block in Simulink.
            icon = 'Tamagawa_Get_Last10_Position_and_Angle';
        end    
    end
    
    methods (Static, Access=protected)
        function simMode = getSimulateUsingImpl(~)
            simMode = 'Interpreted execution';
        end
        
        function isVisible = showSimulateUsingImpl
            isVisible = false;
        end
    end
    
    methods (Static)
        function name = getDescriptiveName()
            name = 'Tamagawa_Get_Last10_Position_and_Angle';
        end
        
        function b = isSupportedContext(context)
            b = context.isCodeGenTarget('rtw');
        end
        
        function updateBuildInfo(buildInfo, context)
            if context.isCodeGenTarget('rtw')
                % Update buildInfo
                srcDir = fullfile(fileparts(mfilename('fullpath')),'src'); %#ok<NASGU>
                includeDir = fullfile(fileparts(mfilename('fullpath')),'include');
                addIncludePaths(buildInfo,includeDir);
                % Use the following API's to add include files, sources and
                % linker flags
                addIncludeFiles(buildInfo,'tamagawa.h',includeDir);
                addSourceFiles(buildInfo,'tamagawa.c',srcDir);
                %addLinkFlags(buildInfo,{'-lSource'});
                %addLinkObjects(buildInfo,'sourcelib.a',srcDir);
                %addCompileFlags(buildInfo,{'-D_DEBUG=1'});
                %addDefines(buildInfo,'MY_DEFINE_1')
            end
        end
    end
end
